# demo05_gen.py
# 生成器函数
def fn():
    a = 1
    # 产出，返回结果的同时，暂停产生的执行
    yield a
    b = 'hello'
    yield b
    c = True
    yield c
    d = [100, 200]
    yield d
    e = {'a': 300, 'b': 400}
    yield e
# <generator object fn at 0x000001BE0E271030>
gen = fn()
# print(gen)
print(gen.__next__())
print(gen.__next__())
for item in gen:
    print(item)